repo: Don't put remote refs in the summary file
authorColin Walters <walters@verbum.org>
Tue, 1 Nov 2016 18:17:57 +0000 (14:17 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 4 Nov 2016 15:16:09 +0000 (15:16 +0000)
I was doing a chain of mirroring like A -> B -> C

And repo B had A as a remote.  When I added B as
a remote to C, the summary file of B had a ref
upstream:foo/bar/baz, which caused all pulls from
B to C to fail, since the summary file is only
expected to have refs, not refspecs.

Closes: https://github.com/ostreedev/ostree/issues/561
Closes: #565
Approved by: jlebon

src/libostree/ostree-repo.c

index 1f866bbe3d900b21eede024832a7f51586b33585..ad6294210a88533023000351ff07be15fd5897ba 100644 (file)
@@ -4668,10 +4668,18 @@ ostree_repo_regenerate_summary (OstreeRepo     *self,
     {
       const char *ref = iter->data;
       const char *commit = g_hash_table_lookup (refs, ref);
+      g_autofree char *remotename = NULL;
       g_autoptr(GVariant) commit_obj = NULL;
 
       g_assert (commit);
 
+      if (!ostree_parse_refspec (ref, &remotename, NULL, NULL))
+        g_assert_not_reached ();
+
+      /* Don't put remote refs in the summary */
+      if (remotename != NULL)
+        continue;
+
       if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, commit, &commit_obj, error))
         goto out;